package com.smobject;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.*;


public class SmPageData extends CSerializeObject<SmPageData> {
	public java.util.List<String> Captions = new ArrayList<String>();
	public java.util.List<java.util.List<String>> Rows = new ArrayList<java.util.List<String>>();
   
	public int RecordCount = 0;
	
	public int PageIndex = 1;

	public int PageSize = 1;
  
	public int PageCount = 1;
   
	public int PageRecordCount = 0;
   
	public int ColumnCount = 0;
    

    public java.util.List<String> getM_strCaptions() {
		return Captions;
	}


	public void setM_strCaptions(List<String> mStrCaptions) {
		Captions = mStrCaptions;
	}


	public List<List<String>> getM_rows() {
		return Rows;
	}


	public void setM_rows(List<List<String>> mRows) {
		Rows = mRows;
	}


	public int getM_RecordCount() {
		return RecordCount;
	}


	public void setM_RecordCount(int mRecordCount) {
		RecordCount = mRecordCount;
	}


	public int getM_PageIndex() {
		return PageIndex;
	}


	public void setM_PageIndex(int mPageIndex) {
		PageIndex = mPageIndex;
	}


	public int getM_PageSize() {
		return PageSize;
	}


	public void setM_PageSize(int mPageSize) {
		PageSize = mPageSize;
	}


	public int getM_PageCount() {
		return PageCount;
	}


	public void setM_PageCount(int mPageCount) {
		PageCount = mPageCount;
	}


	public int getM_PageRecordCount() {
		return PageRecordCount;
	}

	public void setM_PageRecordCount(int mPageRecordCount) {
		PageRecordCount = mPageRecordCount;
	}

	public int getM_ColumnCount() {
		return ColumnCount;
	}

	public void setM_ColumnCount(int mColumnCount) {
		ColumnCount = mColumnCount;
	}


    public void FromDataTable(ResultSet rset)
    {
        if (rset != null)
        {
        	ResultSetMetaData rsmd = null;
			try {
				rsmd = rset.getMetaData();
			} catch (SQLException e2) {
				
				e2.printStackTrace();
			}   
            int columnCount = 0;
			try {
				columnCount = rsmd.getColumnCount();
			} catch (SQLException e1) {
		
				e1.printStackTrace();
			}   
        	try {
				while(rset.next())
				{
					java.util.List<String> d=new ArrayList<String>();
					
					for(int i=1;i<=columnCount;i++){
						String s=rset.getString(i);
						d.add(s);
					}
					Rows.add(d);
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
        	
            PageRecordCount = Rows.size();
        }
    }
  
    
}
